import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss' // global css

import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
import App from './App'
import store from './store'
import router from './router'
import GeminiScrollbar from 'vue-gemini-scrollbar'
Vue.use(GeminiScrollbar)

import '@/icons' // icon
import '@/permission' // permission control
import http from './Yapi'
import elformdesign from './plugin/index'
Vue.use(elformdesign)
Vue.prototype.formatDate = function(time) {
  if (typeof (time) === 'undefined') {
    return ''
  } else {
    const date = new Date(parseInt(time))
    const y = date.getFullYear()
    let MM = date.getMonth() + 1
    MM = MM < 10 ? ('0' + MM) : MM
    let d = date.getDate()
    d = d < 10 ? ('0' + d) : d
    let h = date.getHours()
    h = h < 10 ? ('0' + h) : h
    let m = date.getMinutes()
    m = m < 10 ? ('0' + m) : m
    let s = date.getSeconds()
    s = s < 10 ? ('0' + s) : s
    return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  }
}
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
Vue.prototype.$Http = http
import axios from 'axios'
Vue.prototype.$axios = axios
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   // mockXHR()
// }

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
